package com.zhuqi.util;

import java.util.concurrent.*;

/**
 * <p>线程池</p>

 * @author zhuqi
 * @since 2023/4/13 15:36
 * 
 */
@Deprecated
public class ClientExecutor {

	public static ThreadPoolExecutor executor;

	static {
		initExecutor();
	}

	public static void initExecutor(){
		executor = new ThreadPoolExecutor(2, 3, 30
				, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ExecutionHandler());
	}


	/**
	 * 由调用方继续执行
	 */
	static class ExecutionHandler implements RejectedExecutionHandler {

		@Override
		public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
			if (!executor.isShutdown()) {
				r.run();
			}
		}
	}
}
